package com.jingan.nursinghome.regulatory.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;

import cn.android.support.v7.lib.sin.crown.base.BaseView;
import cn.android.support.v7.lib.sin.crown.utils.ProportionUtils;

/**
 * Created by 彭治铭 on 2017/10/11.
 */

public class ryView extends BaseView {
    public ryView(Context context) {
        super(context);
        init();
    }

    public ryView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    int textSize;

    private void init() {
        textSize = ProportionUtils.getInstance().adapterInt(28);
        textPaint.setTextSize(textSize);
        textPaint.setTextAlign(Paint.Align.LEFT);
    }

    String info;

    public void setInfo(String info) {
        this.info = info;
        invalidate();
    }

    public String getInfo() {
        return info;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        setMeasuredDimension(ProportionUtils.getInstance().adapterInt(600),textSize*2);
    }

    @Override
    public void draw(Canvas canvas) {
        super.draw(canvas);
        if (info != null && !info.trim().equals("")) {
            textPaint.setColor(Color.parseColor("#999999"));
            canvas.drawText("已选 : ", 0, textSize*1.5f, textPaint);
            textPaint.setColor(Color.parseColor("#4B97F0"));
            int x = (int) textPaint.measureText("已选 : ", 0, 5);
            canvas.drawText(info, x, textSize*1.5f, textPaint);
        }
    }
}
